home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / FromTheMag / JW FLV MEDIA PLAYER 4.2 / mediaplayer.exe / player.swf / scripts / com / jeroenwijering / utils / Stretcher.as < prev    next >
Text File  |  2008-11-04  |  2KB  |  67 lines

  1. package com.jeroenwijering.utils
  2. {
  3.    import flash.display.DisplayObject;
  4.    
  5.    public class Stretcher
  6.    {
  7.       
  8.       public static var EXACTFIT:String = "exactfit";
  9.       
  10.       public static var FILL:String = "fill";
  11.       
  12.       public static var NONE:String = "none";
  13.       
  14.       public static var UNIFORM:String = "uniform";
  15.        
  16.       
  17.       public function Stretcher()
  18.       {
  19.          super();
  20.       }
  21.       
  22.       public static function stretch(param1:DisplayObject, param2:Number, param3:Number, param4:String = "uniform") : void
  23.       {
  24.          var _loc5_:Number = NaN;
  25.          var _loc6_:Number = NaN;
  26.          _loc5_ = param2 / param1.width;
  27.          _loc6_ = param3 / param1.height;
  28.          switch(param4.toLowerCase())
  29.          {
  30.             case "exactfit":
  31.                param1.width = param2;
  32.                param1.height = param3;
  33.                break;
  34.             case "fill":
  35.                if(_loc5_ > _loc6_)
  36.                {
  37.                   param1.width *= _loc5_;
  38.                   param1.height *= _loc5_;
  39.                }
  40.                else
  41.                {
  42.                   param1.width *= _loc6_;
  43.                   param1.height *= _loc6_;
  44.                }
  45.                break;
  46.             case "none":
  47.                break;
  48.             case "uniform":
  49.                if(_loc5_ > _loc6_)
  50.                {
  51.                   param1.width *= _loc6_;
  52.                   param1.height *= _loc6_;
  53.                }
  54.                else
  55.                {
  56.                   param1.width *= _loc5_;
  57.                   param1.height *= _loc5_;
  58.                }
  59.          }
  60.          param1.x = Math.round(param2 / 2 - param1.width / 2);
  61.          param1.y = Math.round(param3 / 2 - param1.height / 2);
  62.          param1.width = Math.ceil(param1.width);
  63.          param1.height = Math.ceil(param1.height);
  64.       }
  65.    }
  66. }
  67.